var validator;
var $dictAddForm = $("#dict-add-form");

function saveDictInfo(){
    var validator = $("#dict-add-form").validate();
    var flag = validator.form();
    if(flag){
        $.post(ctx + "dict/add",$("#dict-add-form").serialize(),function(r){
            if(r.code === 0){
                $("#dict-info").modal('hide');
                $JuXue.n_success(r.msg);
                $JuXue.refreshTable("dictTable");
            }else{
                $JuXue.n_danger(r.msg);
            }
        });
    }
}


function validateRule() {
    var icon = "<i class='zmdi zmdi-close-circle zmdi-hc-fw'></i> ";
    validator = $dictAddForm.validate({
        rules: {
            keyy: {
                required: true,
                digits: true,
                maxlength: 10
            },
            valuee: {
                required: true,
                maxlength: 10
            },
            tableName: {
                required: true,
                maxlength: 10
            },
            fieldName: {
                required: true,
                maxlength: 10
            }
        },
        messages: {
            keyy: {
                required: icon + "请输入键名",
                digits: icon + "请输入整数",
                maxlength: icon + "长度不能超过10个字符"
            },
            valuee: {
                required: icon + "请输入键值",
                maxlength: icon + "长度不能超过10个字符"
            },
            tableName: {
                required: icon + "请输入关联表名",
                maxlength: icon + "长度不能超过10个字符"
            },
            fieldName: {
                required: icon + "请输入字段名",
                maxlength: icon + "长度不能超过10个字符"
            }
        }
    });
}